import {dateTypeFormat} from "@/uitls/tool.js"
import { createStore } from 'vuex'
import AddClass from "./modules/AddClass.js"
import mainData from "./modules/mainData.js"
import setting from "./modules/setting.js"
import useData from "./modules/useData.js"
const store = createStore({
	state:{
		// AccountBook 应用名  
		fontSize:16,
		SystemInfo:null,
		theme: null,
		indexShowTime:dateTypeFormat('YYYY-mm-dd', new Date()),
	},
	mutations:{
		getSystemInfo(state){
			uni.getSystemInfo({
				success: function(res) {
					state.theme="#999999"
					setTimeout(()=>{
						state.SystemInfo=res
						state.theme=res.theme=="dark"?"#0f0f22":"#fefeff"
						let getFontSize = res.windowWidth / 30
						// #ifdef H5
						let emPX = parseFloat(getComputedStyle(document.documentElement).fontSize)
						getFontSize = Math.min(emPX, getFontSize)
						// #endif
						state.fontSize =  Math.min(getFontSize,25)
					},0)
				}
			});
		}
	},
	modules:{
		AddClass,
		mainData,
		setting,
		useData
	}
})

export default store